package org.example.controller.teacher;

import org.example.conf.rabbitmqConf;
import org.example.pojo.Result;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin
@RequestMapping("/teacher/push")
public class pushMessage {

    @Autowired
    @Qualifier(value = "rabbitTemplate")
    private RabbitTemplate rabbitTemplate;

    @PostMapping("/message")
    public Result pushMessage(String message){
        System.out.println(message);
       rabbitTemplate.convertAndSend(rabbitmqConf.QUEUE_SEND_MESSAGE,message);
        return Result.builder().data(100).build();
    }

}
